/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.fanyue.modules.face.mapper;

import com.fanyue.modules.face.entity.AppUserFace;
import com.fanyue.modules.face.vo.AppUserFaceVO;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 *  Mapper 接口
 *
 * @author BladeX
 * @since 2022-08-17
 */
public interface AppUserFaceMapper extends BaseMapper<AppUserFace> {

	@Select("select * from wzb_app_user_face where user_id = #{userId}")
	AppUserFace selectUserInfo(Long userId);

	@Select("select search_id from wzb_app_user_face order by search_id desc limit 1")
	Integer selectLastSearchId();

	@Select("select user_id from wzb_app_user_face where search_id = #{searchId}")
	Long selectUserIdBySearchId(@Param("searchId") int searchId);

	@Update("<script>"
		+ "update wzb_app_user_face set is_sync = 1 where user_id in "
		+ "<foreach item='id' index='index' collection='ids' open='(' separator=',' close=')'>"
		+ "#{id}"
		+ "</foreach>"
		+ "</script>")
	Integer confirmUserFace(@Param("ids") List<Long> ids);
}
